package org.xukai.remoting.redis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisMonitor;

/**
 * @author xukai
 * @desc
 * @date 2017-01-02-下午 3:48
 */
public class MonitoringDemo {

    public static void main(String[] args) {
        Jedis jedis = new Jedis("192.168.252.128");
        new Thread(new Runnable() {
            public void run() {
                Jedis j = new Jedis("192.168.252.128");
                for (int i = 0; i < 5; i++) {
                    j.incr("foobared");
                    try {
                        Thread.sleep(200);
                    } catch (InterruptedException e) {
                    }
                }
                j.disconnect();
            }
        }).start();

        jedis.monitor(new JedisMonitor() {
            public void onCommand(String command) {
                System.out.println(command);
            }
        });

    }
}
